import { defHttp } from '/@/utils/http/axios';

enum Api {
  queryDataById = '/entrust/labEntrust/queryById',
  downloadExcel = '/entrust/labEntrust/downloadExcel',
  autoAllotUser = '/items/labTaskAllot/autoAllot',
  handleUsers = '/items/labTaskAllot/handleUsers',
  submitAllot = '/items/labTaskAllot/submitAllot',
  queryItemData = '/items/labTaskAllot/getItemsRecordData',
  queryItemsData = '/items/labTaskAllot/getItemsReportData',
  downloadWord = '/entrust/labEntrust/downloadWord/',


  list = '/items/labTaskAllot/taskList',
  save = '/entrust/labEntrust/add',
  edit = '/entrust/labEntrust/edit',
  userList = '/sys/user/list',
  queryItemsById = '/entrust/labEntrust/queryLabItemsByMainId',
  queryReportData = '/items/report/labItemsRecordReport/queryReportByTaskId',
  saveOrUpdateData = '/items/report/labItemsRecordReport/saveOrUpdateData',
}

/**
 * 下载模板
 * @param params
 */
export const downloadExcel = Api.downloadExcel;
export const getDownloadWord = Api.downloadWord;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({ url: Api.list, params });

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url: url, params });
}

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdateData = (params) => {
  let url = Api.saveOrUpdateData;
  return defHttp.post({ url: url, params }, { isTransformResponse: false });
}
/**
* 根据id查询数据
* @param params
*/
export const queryDataById = (id) => defHttp.get({ url: Api.queryDataById, params: { id } });

/**
 * 子表单信息
 * @param params
 */
export const queryItemsById = (params) =>
  defHttp.get({ url: Api.queryItemsById, params }, { isTransformResponse: false });


  /**
* 根据id查询数据
* @param params
*/
export const autoAllotUser = (mId) => defHttp.get({ url: Api.autoAllotUser, params:mId  });



/**
 * 列表接口
 * @param params
 */
export const handleUsers = (params) =>
  defHttp.get({ url: Api.handleUsers, params });

  /**
 * 保存或者更新
 * @param params
 */
export const submitAllot = (params) => {
  let url =  Api.submitAllot;
  return defHttp.post({ url: url, params });
}

/**
* @param params
*/
export const queryItemData = (params) => defHttp.get({ url: Api.queryItemData, params });


/**
* @param params
*/
export const queryItemsData = (params) => defHttp.get({ url: Api.queryItemsData, params });

/**
* @param params
*/
export const queryReportData = (params) => defHttp.get({ url: Api.queryReportData, params });


  /**
 * 用户列表
 * @param params
 */
  export const getUserList = (params) => {
    return defHttp.get({ url: Api.userList,params });
  };


